using System;
using System.IO;

namespace ns20
{
	internal class Class143
	{
		private const int int_0 = 76;

		private const int int_1 = 57;

		private readonly char[] char_0 = new char[76];

		private readonly TextWriter textWriter_0;

		private byte[] byte_0;

		private int int_2;

		public Class143(TextWriter writer)
		{
			Class204.smethod_2(writer, "writer");
			textWriter_0 = writer;
		}

		public void method_0(byte[] byte_1, int int_3, int int_4)
		{
			if (byte_1 == null)
			{
				throw new ArgumentNullException("buffer");
			}
			if (int_3 < 0)
			{
				throw new ArgumentOutOfRangeException("index");
			}
			if (int_4 < 0)
			{
				throw new ArgumentOutOfRangeException("count");
			}
			if (int_4 > byte_1.Length - int_3)
			{
				throw new ArgumentOutOfRangeException("count");
			}
			if (int_2 > 0)
			{
				int num = int_2;
				while (num < 3 && int_4 > 0)
				{
					byte_0[num++] = byte_1[int_3++];
					int_4--;
				}
				if (int_4 == 0 && num < 3)
				{
					int_2 = num;
					return;
				}
				int int_5 = Convert.ToBase64CharArray(byte_0, 0, 3, char_0, 0);
				method_2(char_0, 0, int_5);
			}
			int_2 = int_4 % 3;
			if (int_2 > 0)
			{
				int_4 -= int_2;
				if (byte_0 == null)
				{
					byte_0 = new byte[3];
				}
				for (int i = 0; i < int_2; i++)
				{
					byte_0[i] = byte_1[int_3 + int_4 + i];
				}
			}
			int num2 = int_3 + int_4;
			int num3 = 57;
			while (int_3 < num2)
			{
				if (int_3 + num3 > num2)
				{
					num3 = num2 - int_3;
				}
				int int_6 = Convert.ToBase64CharArray(byte_1, int_3, num3, char_0, 0);
				method_2(char_0, 0, int_6);
				int_3 += num3;
			}
		}

		public void method_1()
		{
			if (int_2 > 0)
			{
				int int_ = Convert.ToBase64CharArray(byte_0, 0, int_2, char_0, 0);
				method_2(char_0, 0, int_);
				int_2 = 0;
			}
		}

		private void method_2(char[] char_1, int int_3, int int_4)
		{
			textWriter_0.Write(char_1, int_3, int_4);
		}
	}
}
